#include "widget.h"
#include "ui_widget.h"
#include <QtDebug>

#include <fstream>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
//    ui->comboBox->addItem("巨无霸");
//    ui->comboBox->addItem("麦辣鸡翅");

//    ui->comboBox_2->addItem("可乐");
//    ui->comboBox_2->addItem("橙汁");

    std::ifstream ifs;
    ifs.open("D:\\UserData\\Gitee\\qt\\combobox\\menu.txt");
    if(!ifs.good())
    {
        qDebug() << "open failed";
        return;
    }
    std::string str;
    while(std::getline(ifs, str))
    {
        ui->comboBox->addItem(QString::fromStdString(str));
    }
    ifs.close();
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    qDebug() << ui->comboBox->currentText();
}
